package com.qf.cx.simplenms.persist.entity;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

@Entity
@Table(name = "Topic")
public class TopicEntity {
	@Id
	@Column(name = "name")
	private String name;

	@Column(name = "cycle")
	private long cycle;

	@ManyToMany(targetEntity = TagMemoryEntity.class, fetch = FetchType.EAGER)
	@JoinTable(name = "Topic_TagMemory", joinColumns = @JoinColumn(name = "topicName"), inverseJoinColumns = @JoinColumn(name = "tagMemoryName"))
	@Fetch(value = FetchMode.SUBSELECT)
	private List<TagMemoryEntity> tagMemoryEntities;

	@ManyToMany(targetEntity = ReaderGroupEntity.class, fetch = FetchType.EAGER)
	@JoinTable(name = "Topic_ReaderGroup", joinColumns = @JoinColumn(name = "topicName"), inverseJoinColumns = @JoinColumn(name = "readerGroupName"))
	@Fetch(value = FetchMode.SUBSELECT)
	private List<ReaderGroupEntity> readerGroupEntities;

	@ManyToMany(targetEntity = SubscriberEntity.class, fetch = FetchType.EAGER)
	@JoinTable(name = "Topic_Subscriber", joinColumns = @JoinColumn(name = "topicName"), inverseJoinColumns = @JoinColumn(name = "subscriberId"))
	@Fetch(value = FetchMode.SUBSELECT)
	private List<SubscriberEntity> subscriberEntities;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public long getCycle() {
		return cycle;
	}

	public void setCycle(long cycle) {
		this.cycle = cycle;
	}

	public List<TagMemoryEntity> getTagMemoryEntities() {
		return tagMemoryEntities;
	}

	public void setTagMemoryEntities(List<TagMemoryEntity> tagMemoryEntities) {
		this.tagMemoryEntities = tagMemoryEntities;
	}

	public List<ReaderGroupEntity> getReaderGroupEntities() {
		return readerGroupEntities;
	}

	public void setReaderGroupEntities(List<ReaderGroupEntity> readerGroupEntities) {
		this.readerGroupEntities = readerGroupEntities;
	}

	public List<SubscriberEntity> getSubscriberEntities() {
		return subscriberEntities;
	}

	public void setSubscriberEntities(List<SubscriberEntity> subscriberEntities) {
		this.subscriberEntities = subscriberEntities;
	}

}
